const Components = import.meta.globEager('./**/*.vue')
const comps = []

Object.keys(Components).forEach(path => {
  comps.push({
    key: path.replace(/.+\/(\w+)\..+/, (s, m) => m),
    component: Components[path].default
  })
})

export function setupComponents(app) {
  for (let i = 0; i < comps.length; i += 1) {
    const { key, component } = comps[i]

    if (key) {
      app.component(key, component)
    }
  }
}
